--事务循环删除数据
SET STATISTICS TIME ON;
DECLARE @Timer DATETIME = GETDATE();
DECLARE @START_DATE   DATETIME='2021-01-04';
DECLARE @END_DATE   DATETIME='2021-01-50';

WHILE 1 = 1
BEGIN
    BEGIN TRAN
    DELETE FROM [dbo].[H0405] WHERE H_DAT_DT <= @START_DATE;
    COMMIT
    
	IF DATEDIFF(d,@START_DATE,@END_DATE) = 0
        BREAK;
	SET @START_DATE=DATEADD(d,1,@START_DATE);
END



SELECT DATEDIFF(MS, @Timer, GETDATE()) AS [执行时间(毫秒)];
SET STATISTICS TIME OFF;